Matplotlib Tutorial Part 06 - Pie Charts


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt

In [4]:
fig = plt.figure(figsize=(9,9))

# Values
slices = [7,2,2,13]

# Labels
activities = ['sleeping','eating','working','playing']

plt.pie(slices, labels=activities,)

plt.title('Pie Chart')

plt.show()


Pie Chart Customized


In [10]:
fig = plt.figure(figsize=(9,9))

# Values
slices = [7,2,2,13]

# Labels
activities = ['sleeping','eating','working','playing']

# Colours
cols = ['c','m','r','pink']

plt.pie(slices,
        labels=activities,
        colors=cols, # Colours
        startangle=90, # Angle
        shadow=True, # Shadow
        explode=(0.05,0.05,0.05,0.05), # Separation
        autopct="%1.1f%%") # Show %

plt.title('Pie Chart')

plt.show()